<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <p>
      For a guide and recipes on how to configure / customize this project,<br />
      check out the
      <a href="https://cli.vuejs.org" target="_blank" rel="noopener"
        >vue-cli documentation</a
      >.
    </p>
    <h3>Installed CLI Plugins</h3>
    <div>{{ city }} {{ text }} {{ temp }}℃</div>
  </div>
</template>

<script>
import { ref } from "vue";
export default {
  name: "HelloWorld",
  props: {
    msg: String,
  },
  setup(props) {
    console.log(props);
    const city = ref("广州"),
      text = ref(""),
      temp = ref("");
    return {
      city,
      text,
      temp,
    };
  },
  mounted() {
    const demoData = {
      openid: null,
      airportCode: "CAN",
      type: 2,
      page: 1,
      rows: 10,
    };
    this.$http.demo.list(demoData).then((res) => {
      console.log(res);
    });

    this.$http.demo
      .weatherInfo({
        locationName: this.city,
        type: "now",
      })
      .then((res) => {
        console.log(res);
        if (res && res.data) {
          const {
            data: { now },
          } = res;
          this.text = now.text;
          this.temp = now.temp;
        }
      });
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
